Improve response body mismatch error message #65
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reviewer Note: I realize this may not be something you're interested in supporting. It has the down-side of changing behavior based on which modules are available. But I have found it to improve the usefulness of supertest a lot for my use cases and thought you might want to consider it.
If the parsed response body does not match the expected value, the
current output is only really useful in cases where the difference is
readily apparent or the body is small and the difference is in the
outermost object or its child. Otherwise the user may need to scroll
through large amounts of output and the mismatch may not be visible due
to the depth limit of util.inspect.
To make finding the source of inequality easier for users, make use of
either should or Chai assertions (which print very useful messages in
most test frameworks). When neither should nor Chai is available,
include the entire object in the output to allow users to find the
inequality when it is not in the outermost object or its child.
Signed-off-by: Kevin Locke kevin@kevinlocke.name